#ifndef _UTIL_BUFFER_H_
#define _UTIL_BUFFER_H_

#include "xtypes.h"
#include "xaux.h"
#include "xbuffer.h"
#include "util_sync.h"

class CxSafeRingBuffer: public CxRingBuffer, protected CxCriticalSection
{
public:
	memptr_t data();
	int_t size();
	xResult resize( int_t _Size );
	int_t capacity();
	xResult resize_capacity(int_t _NewSize);

	bool_t empty();
	xResult clear();

	xResult insert_front( const wildptr_t _DataPtr, int_t _Size );
	xResult drop_front( int_t _Size );
	xResult copy_front( wildptr_t _DataPtr, int_t _Size );
	xResult cut_front( wildptr_t _DataPtr, int_t _Size );

	xResult insert_back( const wildptr_t _DataPtr, int_t _Size );
	xResult drop_back( int_t _Size );
	xResult copy_back( wildptr_t _DataPtr, int_t _Size );
	xResult cut_back( wildptr_t _DataPtr, int_t _Size );

	xResult insert( int_t _BeginPos, const wildptr_t _DataPtr, int_t _Size );
	xResult drop( int_t _BeginPos, int_t _Size );
	xResult copy( int_t _BeginPos, wildptr_t _DataPtr, int_t _Size );
	xResult cut( int_t _BeginPos, wildptr_t _DataPtr, int_t _Size );

	int_t length();
	memptr_t fragment_ptr();
	int_t fragment_len();
};

#define RingBuffer_t CxSafeRingBuffer


#endif //_UTIL_BUFFER_H_